package com.jf.springmvc.datavalid.bean;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.xml.crypto.Data;
import java.util.Date;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-10-31
 * Time:23:57
 */
public class Person {
    private Integer id;
    @NotEmpty
    private String name;
    @NotNull(message = "年龄不能为空")
    @Range(min = 0, max = 150)
    private Integer age;
    @NotEmpty(message = "邮箱不能为空")
    @Email
    private String email;
    @NotNull(message = "生日不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    @NotNull(message = "资产不能为空")
    @NumberFormat(pattern = "###,###,###.##")
    private Double assets;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public @NotEmpty String getName() {
        return name;
    }

    public void setName(@NotEmpty String name) {
        this.name = name;
    }

    public @Range(min = 0, max = 150) Integer getAge() {
        return age;
    }

    public void setAge(@Range(min = 0, max = 150) Integer age) {
        this.age = age;
    }

    public @Email String getEmail() {
        return email;
    }

    public void setEmail(@Email String email) {
        this.email = email;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Double getAssets() {
        return assets;
    }

    public void setAssets(Double assets) {
        this.assets = assets;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", email='" + email + '\'' +
                ", birthday=" + birthday +
                ", assets=" + assets +
                '}';
    }
}
